home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / Dialog.C < prev    next >
C/C++ Source or Header  |  1992-08-24  |  3KB  |  178 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "Dialog.h"
  6.  
  7. #include "Class.h"
  8. #include "Error.h"
  9. #include "CmdNo.h"
  10. #include "Window.h"
  11. #include "Buttons.h"
  12.  
  13. //---- Dialog ------------------------------------------------------------------
  14.  
  15. NewMetaImpl(Dialog,Manager, (T(actionId)));
  16.  
  17. Dialog::Dialog(char *name, WindowFlags f) : Manager(name, eMgrHide, eWinDialog)
  18. {
  19.     wflags= f;
  20.     actionId= cIdNone;
  21. }
  22.  
  23. Point Dialog::GetInitialWindowSize()
  24. {
  25.     return cAutoSize;
  26. }
  27.  
  28. VObject *Dialog::DoMakeContent()
  29. {
  30.     fprintf(stderr, "Dialog::DoCreateDialog: You should better override DoMakeContent()\n");
  31.     return DoCreateDialog();
  32. }
  33.  
  34. MenuBar *Dialog::DoMakeMenuBar()
  35. {
  36.     return 0;
  37. }
  38.  
  39. void Dialog::EnableItem(int id, bool b)
  40. {
  41.     VObject *vop;
  42.     if (vop= FindItem(id))
  43.     vop->Enable(b, TRUE);
  44. }
  45.  
  46. VObject *Dialog::FindItem(int id)
  47. {
  48.     Window *bw= GetWindow();
  49.     if (bw) {
  50.     VObject *vop= bw->GetViewedVObject();
  51.     if (vop)
  52.         return vop->FindItem(id);
  53.     }
  54.     return 0;
  55. }
  56.  
  57. void Dialog::DoSetDefaults()
  58. {
  59. }
  60.  
  61. void Dialog::DoSave()
  62. {
  63. }
  64.  
  65. void Dialog::DoRestore() 
  66. {
  67. }
  68.  
  69. void Dialog::DoStore() 
  70. {
  71. }
  72.  
  73. void Dialog::DoSetup() 
  74. {
  75. }
  76.  
  77. int Dialog::ShowAt(VObject *fp, Point p)
  78. {
  79.     MakeWindows();
  80.     DoSetDefaults();
  81.     DoSave();
  82.     DoSetup();
  83.     OpenAt(fp, p, TRUE);
  84.     return actionId;
  85. }
  86.  
  87. int Dialog::ShowUnderMouse()
  88. {
  89.     if (gWindow)
  90.     return ShowAt(gWindow, gToken.Pos);
  91.     return 0;
  92. }
  93.  
  94. int Dialog::ShowOnWindow(VObject *fp)
  95. {
  96.     if (fp)
  97.     return ShowAt(fp, fp->GetExtent().Half());
  98.     return ShowUnderMouse();
  99. }
  100.  
  101. Point Dialog::GetInitialPos(Point e)
  102. {
  103.     VObject *dfltButton= GetDefaultButton();
  104.     if (dfltButton)
  105.     return dfltButton->GetPortPoint(dfltButton->contentRect.Center());
  106.     return e.Half();
  107. }
  108.  
  109. void Dialog::Cancel()
  110. {
  111.     actionId= cIdCancel;
  112.     Dismiss();
  113.     DoRestore();
  114. }
  115.  
  116. bool Dialog::AboutToDismiss()
  117. {
  118.     if (GetFirstHandler()) {
  119.     bool rc= GetFirstHandler()->KbdFocus(FALSE);
  120.     if (!rc)
  121.         return FALSE;
  122.     GetFirstHandler()->KbdFocus(TRUE);
  123.     }
  124.     return TRUE;
  125. }
  126.  
  127. void Dialog::Control(int id, int part, void *vp)
  128. {
  129.     if (id != cIdNone && part == cPartAction) {
  130.     actionId= id;
  131.     switch (id) {
  132.     case cIdDefault:
  133.         DoSetDefaults();
  134.         break;
  135.     
  136.     case cIdYes:
  137.     case cIdOk:
  138.         if (Dismiss()) {
  139.         DoStore();
  140.         return;
  141.         }
  142.         break;
  143.     
  144.     case cCLOSE:
  145.     case cIdCancel:
  146.         actionId= cIdCancel;
  147.         Cancel();
  148.         return;
  149.     
  150.     case cIdNo:
  151.         if (Close())
  152.         return;
  153.         break;
  154.         
  155.     case cHELP:
  156.         break;
  157.         
  158.     default:
  159.         if (Dismiss()) {
  160.         DoStore();
  161.         return;
  162.         }
  163.         break;
  164.     }
  165.     }
  166.     Manager::Control(id, part, vp);
  167.     DoSetup();
  168. }
  169.  
  170. //---- obsolete ----------------------------------------------------------------
  171.  
  172. VObject *Dialog::DoCreateDialog()
  173. {
  174.     AbstractMethod("DoMakeContent");
  175.     return 0;
  176. }
  177.  
  178.